<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>显示选中的图片</title>
</head>

<body>





    <form method="post" action="/upload2" enctype="multipart/form-data">
        <input type="file" name="uploadFiles" id="fileInput" value="请选择文件" multiple>
        <input type="submit" value="上传">
    </form>
    <div id="imageContainer"></div>

    <script>
        const fileInput = document.getElementById('fileInput');
        const imageContainer = document.getElementById('imageContainer');

        fileInput.addEventListener('change', function () {
            imageContainer.innerHTML = ''; // 清空容器
            for (let i = 0; i < fileInput.files.length; i++) {
                const file = fileInput.files[i];
                const reader = new FileReader();
                reader.onload = function (e) {
                    const img = document.createElement('img');
                    img.src = e.target.result;
                    img.style.maxWidth = '200px'; // 设置图片的最大宽度
                    img.style.maxHeight = '200px'; // 设置图片的最大高度
                    imageContainer.appendChild(img);
                }
                reader.readAsDataURL(file);
            }
        });
    </script>




</body>

</html>